package com.huaxin.common.Deprecated;

/**
 * Created by hebing on 2016/4/8.
 */
public class BaseInject {

    interface Inject {
        void inject(String methodName, Object... param);
    }


    public static class SimpleInject implements Inject {

        @Override
        public void inject(String methodName, Object... param) {

        }
    }

//    @Target(ElementType.METHOD)
//    @Retention(RetentionPolicy.RUNTIME)
//    public @interface InjectMethod {
//
//    }

    /**
     * If you want a method to be injected, called it!
     *
     * @param param
     */
    public static void Inject(Object... param) {
        final StackTraceElement stack = Thread.currentThread().getStackTrace()[3];

        SimpleInject inject = null;
        try {
            inject = MapCenter.getInject(Class.forName(stack.getClassName()));
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        if (inject != null) inject.inject(stack.getMethodName(), param);
    }

    public static void Inject() {
        final StackTraceElement stack = Thread.currentThread().getStackTrace()[3];

        SimpleInject inject = null;
        try {
            inject = MapCenter.getInject(Class.forName(stack.getClassName()));
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        if (inject != null) inject.inject(stack.getMethodName());
    }
}
